package com.lhs.controller;

import com.lhs.oss.OssUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;

@RestController
@RequestMapping("/file")
public class FileController {

    private final OssUtil ossUtil;

    public FileController(OssUtil ossUtil) {
        this.ossUtil = ossUtil;
    }

    @PostMapping("/upload")
    public String upload(@RequestParam("file") MultipartFile file) throws IOException {
        return ossUtil.upload(file.getInputStream(), file.getOriginalFilename());
    }
}
